package com.pig4cloud.pigx.auth.handler;

import com.pig4cloud.pigx.common.security.handler.AuthenticationSuccessHandler;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @description:
 * @Author 兔子不吃窝边曹
 * @create 2022/8/5 10:05
 **/
@Slf4j
@Component
@AllArgsConstructor
public class PigxAuthenticationSuccessLogEventHandler implements AuthenticationSuccessHandler {

    /**
     * 处理登录成功方法
     *
     * @param authentication 登录对象
     * @param request        请求
     * @param response       返回
     */
    @Async
    @Override
    public void handle(Authentication authentication, HttpServletRequest request, HttpServletResponse response) {
        String username = authentication.getName();
        log.info("用户：{} 登录成功", username);
    }

}
